import { defineStore, storeToRefs } from "pinia";
import createStore from "./user.js";

const dasy = () => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve();
    }, 2000);
  });
};

export default defineStore("storeId", {
  state: () => ({
    age:700,
    count: 0,
    name: "xiaohong",
    number: 1,
    price: 0,
    objLists:[1,2,3],
    numCount:0 //同源标签页通信需要
  }),
  getters: {
    double(state) {
      const userStores = createStore();
      return state.count * 2 + userStores.age;//userStores.age获取user.js中state中的值
    },
    doubleCountPlusOne() {
      return this.double + 1 //this.double获取getters中其他的值
    },
    GetCount(state) {
      const userStores = createStore();
      return (v) => state.number * v + userStores.doubleAge //userStores.doubleAge获取user.js中getters中的值
    }
  },
  actions: {
    async chngeName(val) {
      return 333
    },
  },
});
